<template>
  <div class="goodDetail_container">
    <div class="header-div">
      <div class="logo-div">
        <img src="@/assets/images/logo.png" alt="无法加载图片" />
      </div>
    </div>
    <div class="body-div">
      <Nav />
      <div class="location-div">
        <div class="parcel-div">
          <router-link to="/homePage">首页</router-link>
          <span>&nbsp;&nbsp;/&nbsp;&nbsp;</span>
          <!-- 商品详情 -->
          <a class="goods-link" href="./details-of-goods.html">商品详情</a>
        </div>
      </div>
      <div class="goods-show-div">
        <div class="parcel-div">
          <div class="goods-img">
            <img :src="goodsDetail.cmImg" alt="无法加载图片" />
          </div>
          <div class="goods-detail">
            <h2>{{ goodsDetail.cmName }}</h2>
            <h4>{{ goodsDetail.cmDetails }}</h4>
            <span>￥{{ goodsDetail.cmPrice }}0</span>
            <div class="sort">
              <span>颜色分类</span>
              <!-- <div class="goods-color-sort">
                <div>
                  <img src="../img/goodsPreview/xx103/color-sort/green-xx103.jpg" alt="" />
                  <div class="color-text"><span>绿色</span></div>
                </div>
                <div>
                  <img src="../img/goodsPreview/xx103/color-sort/orange-xx103.jpg" alt="" />
                  <div class="color-text"><span>橙色</span></div>
                </div>
                <div>
                  <img src="../img/goodsPreview/xx103/color-sort/pink-xx103.jpg" alt="" />
                  <div class="color-text"><span>粉色</span></div>
                </div>
                <div>
                  <img src="../img/goodsPreview/xx103/color-sort/white-xx103.jpg" alt="" />
                  <div class="color-text"><span>白色</span></div>
                </div>
              </div> -->
              <div class="repertory">
                <span>库存</span>
                <span class="goods-amount">2000</span>
                <span>件</span>
              </div>
              <div class="btn">
                <button class="reduce">-</button>
                <span class="select-amount">1</span>
                <button class="increase">+</button>
              </div>
            </div>
            <div class="goods-control">
              <button class="buy">立即购买</button>
              <button class="add-gwc">加入购物车</button>
            </div>
            <div class="tip">
              <span>加入购物车成功</span>
            </div>
          </div>
        </div>
        <div class="goods-show">
          <div class="parcel-div">
            <img src="" alt="" />
          </div>
        </div>
        <div class="goods-show-big">
          <img v-for="item in imageList" :key="item.iid" :src="item.iimg" alt="无法加载图片" />
          <img src="@/assets/images/price_illustrate.jpg" alt="无法加载图片" />
        </div>
      </div>
      <div class="main-footer-div">
        <Footer />
      </div>
      <Broad />
    </div>
  </div>
</template>

<script>
import Nav from '@/components/common/MyNav.vue'
import Broad from '@/components/common/MyBroad.vue'
import Footer from '@/components/common/MyFooter.vue'
export default {
  name: 'goodDetail',
  props: ['id'],
  data() {
    return {
      goodsDetail: {},
      imageList: []
    }
  },
  created() {
    this.getGoodsDetail()
  },
  methods: {
    getGoodsDetail() {
      this.$http
        .get('/commodity/goodsDetail/' + this.id)
        .then(res => {
          this.goodsDetail = res.data
        })
        .catch(err => this.$message.error(err))
      this.$http
        .get('/image/goodsImage/' + this.id)
        .then(res => {
          this.imageList = res.data
        })
        .catch(err => this.$message.error(err))
    }
  },
  components: {
    Nav,
    Broad,
    Footer
  }
}
</script>

<style lang="less" scoped>
.header-div {
  width: 80%;
  margin: 0 auto;
}

.logo-div {
  float: left;
  margin-top: 2%;
  margin-bottom: 1%;
}

.form-div {
  float: right;
  margin-top: 2%;
  border-bottom: 1px solid rgba(0, 0, 0, 0.5);
  form {
    display: flex;
  }
  input:nth-child(1) {
    width: 87%;
    height: 2em;
    border: none;
    outline: none;
    font-size: 16px;
    padding: 5px 0px 5px 10px;
  }
  input:nth-child(2) {
    width: 10%;
    border: none;
    cursor: pointer;
    margin-left: 5px;
    background-color: #fff;
    background-position: center;
    background-repeat: no-repeat;
    background-image: url('@/assets/images/ss.png');
  }
}

.header-div::after {
  content: '';
  clear: both;
  display: block;
}

.goodDetail_container {
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  position: absolute;
}

.goods-show-div {
  display: flex;
  padding: 20px;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  background-color: #f5f5f5;
  > .parcel-div {
    display: flex;
    width: 1100px;
    justify-content: space-between;
  }
  .goods-img {
    width: 45%;
    font-size: 0;
    margin-right: 20px;
  }
  .goods-img img {
    width: 100%;
    height: 542px;
    user-select: none;
  }
  .goods-detail {
    width: 50%;
    display: flex;
    padding: 20px;
    position: relative;
    flex-direction: column;
  }
  .goods-detail h2 {
    line-height: 50px;
    user-select: none;
    font-weight: normal;
  }
  .goods-detail h4 {
    padding: 5px 10px;
    user-select: none;
    font-weight: normal;
    font-family: '宋体';
  }
  .goods-detail > span {
    font-size: 2em;
    color: #a10000;
    user-select: none;
    padding: 0 0 10px 5px;
  }
  .goods-detail > span {
    font-size: 2em;
    color: #a10000;
    user-select: none;
    padding: 0 0 10px 5px;
  }
  .goods-detail .sort {
    display: flex;
    margin: 0 10px;
    padding: 20px 20px;
    flex-direction: column;
    border-top: 1px solid #dbdbdb;
    border-bottom: 1px solid #dbdbdb;
  }
  .goods-detail .tip {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
    display: none;
    padding: 10px 15px;
    border-radius: 5px;
    position: absolute;
    width: fit-content;
    height: fit-content;
    background-color: rgba(0, 0, 0, 0.5);
  }
  .goods-detail .tip span {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.9);
  }
  .goods-color-sort {
    font-size: 0;
    display: flex;
    padding-top: 10px;
  }
  .goods-color-sort > div {
    text-align: center;
    margin-right: 10px;
    border: 1px solid #fff;
  }
  .goods-color-sort img {
    width: 80px;
    height: 80px;
    cursor: pointer;
    user-select: none;
  }
  .sort span {
    user-select: none;
  }
  .goods-img,
  .goods-detail {
    background-color: #fff;
    border: 1px solid #dbdbdb;
  }
  .repertory {
    padding: 15px 0;
    .goods-amount {
      color: rgba(255, 0, 0, 0.5);
    }
  }
  .btn {
    display: flex;
    align-items: center;
  }
  button {
    cursor: pointer;
    padding: 5px 10px;
    border: 1px solid #dbdbdb;
  }
  .select-amount {
    width: 40px;
    text-align: center;
    display: inline-block;
  }
  .goods-control {
    display: flex;
    padding: 30px 50px;
    justify-content: space-between;
  }
  .buy {
    color: #fff;
    padding: 10px 40px;
    border-radius: 5px;
    transition: all 0.5s ease;
    background-color: #a10000;
    border: 1px solid #dbdbdb;
  }
  .buy:hover {
    color: #a10000;
    background-color: #fff;
  }
  .add-gwc {
    padding: 10px 30px;
    border-radius: 5px;
    background-color: #fff;
    transition: all 0.5s ease;
    border: 1px solid #dbdbdb;
  }
  .add-gwc:hover {
    color: #fff;
    background-color: #a10000;
  }
  .goods-show {
    width: 1100px;
    padding: 15px 0;
    user-select: none;
    > .parcel-div {
      width: 45%;
      display: flex;
      padding: 5px 0;
      justify-content: center;
      background-color: #fff;
      border: 1px solid #dbdbdb;
    }
    .parcel-div div {
      font-size: 0;
      margin: 0 15px;
      border: 1px solid #fff;
    }
    .parcel-div div:hover {
      border-color: #000;
    }
    img {
      width: 80px;
      height: 80px;
    }
  }
  .goods-show-big {
    width: 1100px;
    display: flex;
    user-select: none;
    align-items: center;
    flex-direction: column;
    .parcel-div div {
      text-align: center;
    }
    img {
      width: 80%;
    }
  }
}

.body-div {
  > .nav-div {
    font-size: 0;
    text-align: center;
    position: relative;
    background-color: #fff;
    border-top: 1px solid #dbdbdb;
    border-bottom: 1px solid #dbdbdb;
  }
  a {
    position: relative;
  }
  > .nav-div li > a::after {
    left: 0;
    bottom: 0;
    width: 100%;
    height: 3px;
    content: '';
    position: absolute;
    transform: scaleX(0);
    transition: all 0.5s ease;
    background-color: #a10000;
  }
  > .nav-div li a:hover:after {
    transform: scaleX(1);
    transition-timing-function: cubic-bezier(0.52, 1.64, 0.37, 0.66);
  }
  .nav-div li {
    padding: 0 10px;
    line-height: 45px;
    display: inline-block;
  }
}

/********************* location-div *********************/
.location-div {
  top: 0;
  z-index: 1;
  position: sticky;
  background-color: #fff;
  border-top: 1px solid #dbdbdb;
  border-bottom: 1px solid #dbdbdb;
  a {
    cursor: pointer;
    font-size: 14px;
    display: inline-block;
  }
  .parcel-div {
    width: 80%;
    margin: 0 auto;
    line-height: 40px;
  }
}

/********************* 主页下拉框 *********************/
.dropdown-content-one {
  left: 0;
  top: 46px;
  z-index: 2;
  width: 100%;
  display: none;
  position: absolute;
  background-color: #fff;
  box-shadow: inset 0px -16px 16px 0px rgba(0, 0, 0, 0.2);
}

.dropdown-content-one .wrapper {
  width: 60%;
  display: flex;
  margin: 0 auto;
  justify-content: center;
}

.dropdown-content-one .wrapper a {
  width: 25%;
  line-height: 0;
  margin-top: 20px;
  padding: 0 20px 20px 20px;
  border-right: 1px solid #dbdbdb;
}

.dropdown-content-one .wrapper a:last-child {
  border-right: none;
}

.dropdown-content-one .dropdown-text-div {
  line-height: 40px;
}

/********************* wrapper-div *********************/
.wrapper-div {
  position: relative;
  padding: 20px 0 20px 0;
  background-color: #f5f5f5;
  border-bottom: 1px solid #dbdbdb;
}

.wrapper-div .userManage-div {
  left: 20px;
  width: 40px;
  height: 40px;
  padding: 5px;
  display: flex;
  cursor: pointer;
  position: absolute;
  text-align: center;
  transition: all 1s ease;
  background-color: #fff;
  border: 1px solid #dbdbdb;
}

.wrapper-div .userManage-div:hover {
  border: 1px solid #a10000;
  background-color: #a10000;
}

.wrapper-div .userManage-div:hover a {
  color: rgba(255, 255, 255, 0.9);
}

.wrapper-div > .parcel-div {
  width: 80%;
  margin: 0 auto;
}

.wrapper-div .parcel-div::after {
  content: '';
  clear: both;
  display: block;
}

.main-footer-div .top-div {
  padding: 25px 0;
  border-top: 1px solid #dbdbdb;
}

.main-footer-div .parcel-div {
  width: 80%;
  display: flex;
  margin: 0 auto;
}

.main-footer-div .parcel-div > div {
  width: 25%;
  text-align: center;
  border-right: 1px solid #dbdbdb;
}

.main-footer-div .parcel-div > div:last-child {
  border-right: none;
}

.main-footer-div span {
  font-size: 16px;
  padding-left: 5px;
}

.main-footer-div .clearfix {
  display: flex;
  align-items: center;
  justify-content: center;
}

.main-footer-div .botton-div {
  font-size: 14px;
  text-align: center;
  padding: 20px 0 20px 0;
  background-color: black;
  color: rgb(255, 255, 255);
}

.broadside-nav {
  top: 400px;
  right: 20px;
  position: fixed;
}

.broadside-nav a {
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.5s ease;
}

.broadside-nav img {
  width: 50%;
  height: 50%;
}

.broadside-nav div {
  width: 50px;
  height: 50px;
  margin-bottom: 10px;
  border: 1px solid #dbdbdb;
  background-color: #fff;
}

.broadside-nav span {
  color: #fff;
  display: none;
  font-size: 13px;
}

.broadside-nav .hidden-div {
  display: none;
  margin-bottom: 0;
}

.broadside-nav a:hover {
  background-color: #a10000;
}

.broadside-nav a:hover img {
  display: none;
}

.broadside-nav a:hover span {
  display: block;
}

.broadside-nav .hidden-p {
  top: 67px;
  left: -155px;
  display: none;
  padding: 10px;
  font-size: 14px;
  position: absolute;
  transition: all 1s ease;
  background-color: #fff;
  border: 1px solid #a10000;
}

.broadside-nav .hidden-p::after {
  top: 50%;
  right: -6px;
  content: '';
  margin-top: -6px;
  position: absolute;
  border-left: 6px solid #a10000;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}

.body-div > .nav-div {
  font-size: 0;
  text-align: center;
  position: relative;
  background-color: #fff;
  border-top: 1px solid #dbdbdb;
  border-bottom: 1px solid #dbdbdb;
}

.body-div > .nav-div a {
  position: relative;
}

.body-div > .nav-div li > a::after {
  left: 0;
  bottom: 0;
  width: 100%;
  height: 3px;
  content: '';
  position: absolute;
  transform: scaleX(0);
  transition: all 0.5s ease;
  background-color: #a10000;
}

.body-div > .nav-div li a:hover:after {
  transform: scaleX(1);
  transition-timing-function: cubic-bezier(0.52, 1.64, 0.37, 0.66);
}

.body-div .nav-div li {
  padding: 0 10px;
  line-height: 45px;
  display: inline-block;
}

.nav-div li a {
  display: block;
  padding: 0 10px;
  cursor: pointer;
  font-size: 16px;
}

a {
  text-decoration: none;
  color: rgba(0, 0, 0, 0.7);
}
</style>
